package com.student.wym.service.impl;

import com.student.wym.mapper.ExamMapper;
import com.student.wym.po.Exam;
import com.student.wym.service.IExamService;
import com.student.wym.util.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class ExamServiceImpl implements IExamService {

    @Autowired
    private ExamMapper examMapper;

    @Override
    public Exam findCurrentExam() {
        Exam exam = examMapper.findCurrentExam();
        return exam;
    }

    @Override
    public PageList findAll() {
        PageList resultList = new PageList();
        resultList.setTotal(examMapper.findTotal());
        resultList.setRows(examMapper.findAll());
        return resultList;
    }

    @Override
    public void delete(int id) {
        examMapper.delete(id);
    }

    @Override
    public void saveOne(Exam exam) {
        Date date = new Date();
        exam.setCreateTime(date);
        examMapper.saveOne(exam);
    }

    @Override
    public Integer findNot() {
        return examMapper.findNot();
    }

    @Override
    public void endCurrentExam() {
        examMapper.endCurrentExam();
    }

    @Override
    public void startCurrentExam() {
        examMapper.startCurrentExam();
    }

    @Override
    public Exam findCurrentExam2() {
        return examMapper.findCurrentExam2();
    }

}
